// 同步歌曲播放cd唱片的旋转
import { usePlayerStore } from '@/stores/playerStore'
export default function useSyncWrapperTransform(outerClassName: string, innerClassName: string) {
  const playerStore = usePlayerStore()
  watch(
    () => playerStore.playing,
    (newVal: boolean) => {
      if (!newVal) {
        const outerEle: NodeListOf<HTMLElement> = document.querySelectorAll(outerClassName),
          innerEle: NodeListOf<HTMLElement> = document.querySelectorAll(innerClassName)
        if (outerEle.length === 0 || innerEle.length === 0) {
          return
        }
        const index = playerStore.sequenceList.findIndex(
          (item: ISongItem) => item.id === playerStore.currentSong?.id
        )
        if (!outerEle[index] || !innerEle[index]) {
          return
        }
        const outerTransformStyle = getComputedStyle(outerEle[index]).transform
        const innerTransformStyle = getComputedStyle(innerEle[index]).transform
        outerEle[index].style.transform =
          outerTransformStyle === 'none'
            ? innerTransformStyle
            : innerTransformStyle.concat(` ${outerTransformStyle}`)
      }
    }
  )
}
